package hanlder

import (
	"github.com/gin-gonic/gin"
	"user/repo-masterss/models"
)

func Add(c *gin.Context) {
	name := c.PostForm("name")
	add := c.PostForm("add")
	if name == "" || add == "" {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "字段不能为空",
		})
		return
	}
	data := models.Cang{
		Name: name,
		Add:  add,
	}
	models.DB.Create(&data)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
